using System;

namespace DemonstrationWebsite.ClientSideGridDemo
{
    public partial class ClientSideGrid : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SalesGrid.Model["Records"] = SalesDataAccess.GetSalesRecords();
                SalesGrid.Model["GridState"] = new GridState();
            }
        }

        /// <summary>
        /// In jMVC.NET, your model can hold any combination of strongly-typed .NET objects and loosely-typed
        /// Javascript objects (use "Newtonsoft.Json.JavaScriptObject"). It's your choice. The appropriate 
        /// conversions happen automatically, so you can access both types both on the server and on the client.
        /// 
        /// In this case, we're providing a strong type for the grid's state, which would be useful if you wanted
        /// to manipulate it on the server (though we don't in this example).
        /// </summary>
        private class GridState
        {
            #pragma warning disable 0169, 0414 // Disable warnings for unused or unassigned fields as they're set by reflection

            public string SortProperty;
            public bool SortDescending;
            public int PageIndex;
            public int SelectedRecordID;

            #pragma warning restore 0169, 0414 // Re-enable above warnings
        }
    }
}
